package com.example.login.Mapper;

import com.example.login.Pojo.MobilePhone;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface MobilePhoneMap
{
    @Insert("insert into xtshop_mobilephone" +
            " (id,sku_code,color,ROM,RAM,image,price,num,network,combination,status,introduction)" +
            " values(#{id},#{sku_code},#{color},#{ROM},#{RAM},#{image},#{price},#{num},#{network},#{combination},1,#{introduction})")
    void Register(int id,String sku_code,String color,String ROM,String RAM,String image,int price,int num,String network,String combination,String introduction);
    @Select("select * from xtshop_mobilephone where id=#{id} and sku_code=#{sku_code}")
    MobilePhone getMobilePhoneInformation(int id, String sku_code);
    @Update("update xtshop_mobilephone SET price=#{price},num=#{num},combination=#{combination},introduction=#{introduction},image=#{image}" +
            "where id=#{id} and sku_code=#{sku_code}")
    void UpdateMobilePhone(int id,String sku_code,int price,int num,String combination,String introduction,String image);
    @Delete("DELETE FROM xtshop_mobilephone WHERE id=#{id} AND sku_code=#{sku_code}")
    void DeleteMobilePhone(int id,String sku_code);
    @Select("select * from xtshop_mobilephone where id=#{id}")
    List<MobilePhone> getMobilePhoneById(int id);
    @Select("select image from xtshop_mobilephone where id=#{id} and sku_code=#{sku_code}")
    String getImage(int id ,String sku_code);
    @Select("select price from xtshop_mobilephone where id=#{id} and sku_code=#{sku_code}")
    int getPriceById(int id ,String sku_code);
}
